import { NextApiRequest, NextApiResponse } from "next";
import { initORM } from "../../../utils/orm";
import { User } from "../../../entities/User";
import { getEndpoint } from "@/services";

async function getEndpointInfo(
  req: NextApiRequest,
  res: NextApiResponse<APIRes>
) {
  const result = await getEndpoint(req);

  res.status(result.success ? 200 : 400).json(result);
}

export default async function handler(
  req: NextApiRequest,
  res: NextApiResponse<APIRes>
) {
  if (req.method === "GET") {
    getEndpointInfo(req, res);
  } else {
    res.status(405).json({
      success: false,
      data: {},
      message: "Method not allowed",
    });
  }
}
